//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet.Pivot
{
    class CacheSource: IOfficeXmlSerializable
    {
        SourceType _type;
        UInt32 _connectionId;

        #region IOfficeXmlSerializable Members

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read("cacheSource"))
            {
                    _type = c.GetEnum<SourceType>("type");
                _connectionId = c.GetOptionalUInteger("connectionId", 0);

                WorksheetSource = c.ReadOptionalElement<WorksheetSource>("worksheetSource");
                Consolidation = c.ReadOptionalElement<Consolidation>("consolidation");
                Extension = c.ReadOptionalElement<ExtensionElement>("extLst");
            }
        }

        public void WriteXml(WriteContext context)
        {
            
            using (var c = context.Write("cacheSource"))
            {
                c.SetEnum("type", _type);
                c.SetOptionalUInteger ("connectionId",_connectionId,0);
                c.WriteOptionalElement(_worksheetSource);
                c.WriteOptionalElement(_consolidation);
                c.WriteOptionalElement(_extLst);
            }
        }

        #endregion
        private WorksheetSource _worksheetSource;

        public WorksheetSource WorksheetSource
        {
            get { return _worksheetSource; }
            set { _worksheetSource = value; }
        }
        private Consolidation _consolidation;

        public Consolidation Consolidation
        {
            get { return _consolidation; }
            set { _consolidation = value; }
        }
        private ExtensionElement _extLst;

        public ExtensionElement Extension
        {
            get { return _extLst; }
            set { _extLst = value; }
        }
	
	
	
    }
}
